
<?

require_once ("application.list.inc");

global $_GLOBAL_DBH;
global $_OBJECT_IFACE_PANEL;

$indexes = array (
	title=>array (label=>"Title",order=>"DEFAULT",wrapper=>"vmc_icon_task"),
	lead_user=>array (label=>"Task Lead",order=>"DEFAULT",wrapper=>"vmc_icon_user"),
	milestone_title=>array (label=>"Milestone",order=>"DEFAULT",wrapper=>"vmc_icon_milestone"),
	details=>array (label=>"Details",order=>"DEFAULT",wrapper=>"vmc_icon_detail"),
	total_time=>array (label=>"Total Time",order=>"DEFAULT",wrapper=>"vmc_icon_total_time"),
	cdate=>array (label=>"Create Date",order=>"DEFAULT",wrapper=>"vmc_icon_date"),
);

$object_ctl = "/admin/projects/projects/fs_projects.php?fs_tab=tasks&project_id={$_REQUEST["project_id"]}&fs_tab_option=fs_tasks&fs_action=view&";
$link_options = "&fs_tab=phases&project_id={$_REQUEST["project_id"]}&fs_tab_option=fs_phases&fs_action=view&fs_tab_phases=tasks&phase_id={$_REQUEST["phase_id"]}";
$list_options = array ();

$_OBJECT_IFACE_LIST = _app_create_list_object (array (
                db_conn=>$_GLOBAL_DBH,
                indexes=>$indexes,
		list_count=>"SELECT COUNT(*) FROM project_milestone_tasks,project_milestones WHERE project_milestones.phase_id={$_REQUEST["phase_id"]} AND project_milestones.id=project_milestone_tasks.milestone_id",
		list_select=>"SELECT project_tasks.*,project_milestones.title AS milestone_title,
			(SELECT CONCAT(last,', ',first)
				FROM users
				WHERE id=project_tasks.assigned_id)
			AS lead_user,
			/* (SELECT CASE current_id WHEN '0' THEN 'Unassigned' ELSE CONCAT(last,', ',first) END
				FROM users
				WHERE id=current_id)
			AS current_user, */
			(SELECT SEC_TO_TIME(SUM(
					CASE project_task_timer.date_end
						WHEN '' THEN UNIX_TIMESTAMP()
						ELSE UNIX_TIMESTAMP(project_task_timer.date_end)
					END - UNIX_TIMESTAMP(project_task_timer.date_begin)))
				FROM project_task_timer
				WHERE task_id=project_tasks.id)
			AS total_time
		FROM project_milestone_tasks,project_milestones,project_tasks,users WHERE project_milestones.phase_id={$_REQUEST["phase_id"]} AND project_milestones.id=project_milestone_tasks.milestone_id AND project_milestone_tasks.task_id=project_tasks.id AND project_tasks.assigned_id=users.id",
                list_id=>"lc_project_phase_tasks",
                list_options=>$list_options,
                primary_key=>"id",
                primary_relation=>"task_id",
                link_options=>$link_options,
                object_ctl=>$object_ctl
));

$_OBJECT_IFACE_TABBING_PANEL->insert_container ($_OBJECT_IFACE_LIST);

?>
